package com.qfedu.zy.controllers;

import com.qfedu.zy.handler.ZanHandler;
import com.qfedu.zy.pojos.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/zan")
public class ZanController {

    @Autowired
    private ZanHandler zanHandler;

    @RequestMapping("/add.do")
    @ResponseBody
    public void add(HttpServletRequest request, String itemId){
        User user = (User) request.getSession().getAttribute("user");
        int userId = user.getUserId();
        System.out.println(itemId+"/t"+userId);
        zanHandler.addZan(itemId,userId);
        zanHandler.countZan(itemId);
    }

}
